import axios from "axios"
import { Button, message, Space } from 'antd';
const instance = axios.create();

instance.defaults.timeout = 2500;
// Add a request interceptor
instance.interceptors.request.use(function (config) {
    // Do something before request is sent
    return config;
  }, function (error) {
    // Do something with request error
    return Promise.reject(error);
  });

// Add a response interceptor
instance.interceptors.response.use(function (response) {
    if (response.status == "200") {
        message.success("接口请求成功")
    } 
    // Do something with response data
    return response;
  }, function (error) {
    if(error.response.status == "404" ) {
        message.error('接口没找到');
    } else if (error.response.status == "500") {
        message.error("服务端错误")
    } else {
        message.error("未知错误")
    }

    // Do something with response error
    return Promise.reject(error);
  });
export default instance